package org.lemon.cla.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.models.OpenAPI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@OpenAPIDefinition(
        // 这里必须与下面的 @SecurityScheme 的 name 保持一致
        security = @SecurityRequirement(name = "Authorization"), // <-- 确保这里是 "Authorization"
        info = @Info(
                title = "那一年的忧郁",
                version = "1.0",
                description = "Java校园小助手文档 \n注意事项：\n1. 枚举类不需要就传null，不要传空字符串，其他无约束字段可以是空串 \n 2. 登录和注册不需要token，添加token会报500",
                contact = @Contact(
                        name = "🐎+7",
                        url = "https://baike.baidu.com/link?url=3tNXoD6si2_THNY5zJoWMlIWxU16gRqdcknOAIWEdVKfubpBrDeGuvgiP92eAEm-DJ_9VQ_5F3EbeFcxwisTlo4DV71OeWishHqOzOV17qy"
                )
        )
)
@SecurityScheme(
        name = "Authorization", // <-- 确保这里也是 "Authorization"
        type = SecuritySchemeType.HTTP,
        scheme = "bearer",
        bearerFormat = "JWT",
        in = SecuritySchemeIn.HEADER,
        description = "JWT Token"
)
@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI springOpenAPI() {
        return new OpenAPI();
    }
}